package tech.xs.sys.domain.bo.dict;

import cn.hutool.core.util.StrUtil;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import tech.xs.common.framework.domain.bo.PageBo;
import tech.xs.sys.domain.entity.SysChildDict;
import tech.xs.sys.domain.entity.SysDict;

/**
 * @author 沈家文
 * @since 2023/5/30 19:52
 */
@Getter
@Setter
@ToString
public class PageChildDictBo extends PageBo<SysChildDict> {

    private String dictCode;
    private String likeCode;

    private String likeName;

    public MPJLambdaWrapper<SysChildDict> query() {
        return new MPJLambdaWrapper<SysChildDict>()
                .selectAll(SysChildDict.class)
                .leftJoin(SysDict.class, SysDict::getId, SysChildDict::getDictId)
                .eq(StrUtil.isNotBlank(dictCode), SysDict::getCode, dictCode)
                .like(StrUtil.isNotBlank(likeName), SysChildDict::getName, likeName)
                .like(StrUtil.isNotBlank(likeCode), SysChildDict::getCode, likeCode)
                .orderByAsc(SysChildDict::getCreatedTime);
    }
}
